package com.lwm.annotationandreflection.ref;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @author liweimin
 * @date 2020/9/25 11:27
 * @description 获取类的运行时结构
 */
public class ref07 {
    public static void main(String[] args) throws ClassNotFoundException {
        Class clazz = Class.forName("com.lwm.annotationandreflection.ref.Son");
        //获得类名
        System.out.println(clazz.getName());
        //获得简单类名
        System.out.println(clazz.getSimpleName());
    //获得类的属性(public)
        System.out.println(clazz.getFields());
        //获得所有属性
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            System.out.println(field);
        }
        //获得本类和父类的所有公共方法
        Method[] methods = clazz.getMethods();
        //获得本类的所有方法
        Method[] declaredMethods = clazz.getDeclaredMethods();
        //获得构造器
        Constructor[] constructors = clazz.getConstructors();
        Constructor[] declaredConstructors = clazz.getDeclaredConstructors();

    }
}
